package com.demo.wormhole.core.configuration;

import javax.annotation.Resource;

public class WormholeIsolationConfiguration {
    
    @Resource
    private WormholePropertiesConfiguration propertiesConfiguration;
    
    /**
     * 生成隔离Key
     *
     * @param key
     * @return
     */
    public String generateIsolationKey(String key) {
        //添加前缀后缀
        return propertiesConfiguration.getIsolationPrefix() + key + propertiesConfiguration.getIsolationSuffix();
    }
    
    /**
     * 检查是否已经添加前缀后缀的key
     *
     * @return
     */
    public boolean checkIsolation(String key) {
        return key.startsWith(propertiesConfiguration.getIsolationPrefix()) && key.endsWith(propertiesConfiguration.getIsolationSuffix());
    }
    
}
